Computer system, virtual machine, runtime representation of object, storage media and program transmission apparatus

ABSTRACT

The invention provides a representation method for an object that is fast and has an extremely little effect on the execution efficiency of a processing system. A computer system that implements an object-oriented programming language according to the invention as runtime representation for an object in programming language that is implemented, comprises an object, a type information block, and a class structure, wherein the object has a header including a pointer to the type information block, wherein the type information block has a class pointer pointing to the class structure, wherein a plurality of class pointers are provided depending on the number of states of the object and individual class pointers are associated with individual states of the object, and wherein the pointer included in the header of the object uses lower bits to point to the class pointers individually in order to represent the states of the object.

FIELD OF THE INVENTION

[0001] The present invention relates to a method for runtime representation for an object to execute a program in a computer system that implements an object-oriented programming language.

[0002] In a computer system where an object-oriented programming language such as Java, Smalltalk, C++ is implemented, it is essential to provide runtime representation of a state of the object in order to execute a program described in such a programming language. How to provide this runtime representation of the state of the object has a crucial effect on the execution efficiency of a processing system.

[0003]FIG. 5 depicts the arrangement of an object that is typically used in implementation of an object-oriented programming language. Referring to FIG. 5, typically an object 110 has a header 111 and a body of instance variables 112, and uses one word in the header 111 to store a pointer to a type information block 120.

[0004] A type information block 120 is composed of a class pointer 121 and a virtual method table 122. The class pointer 121 points to a class structure 130 that aggregates information on the class of the object 110. The class structure 130 includes a large amount of information of the highest importance in the runtime system. When a pointer to the object 110 is given in the object configuration like this, either the reference of a member of the class structure 130 or the reference of a virtual method table 122 is performed. The reference of a member of the class structure 130 is performed in many cases such as upon casting, replication, class loading, compiling, etc., while the reference of a virtual method table 122 is performed upon the calling of a virtual function.

[0005] As runtime representation of a state of the object, making use of bits in the above mentioned header 111 of the object 110 is a simple and fastest method. In this case, the number of state representations that can be represented depends on the number of available bits in the header 111 of the object 110.

[0006] There is also another method where the type information block 120 is located at an appropriate boundary(e.g. 32 byte boundary) and the lower bits(e.g. five bits) of the pointer to the type information block 120 are used for representing the state of the object 110. This method needs logical operations to take out a pointer to the type information block 120.

[0007]FIG. 6 shows, in the object configuration shown in FIG. 5, an example of operation codes when executing an operation to refer to a member located in offset “o” in the class structure 130(operation 1) and an operation to call a method that corresponds to an index “i” in the virtual method table 122(operation 2).

[0008] In each code shown in FIG. 6, “load” reads a value into a register(e.g. “load r12, [r3]” loads into r12 the contents of the memory location whose address is given by the contents of r3), and “call” calls a function call with a register. FIG. 7 shows a modification of operation codes shown in FIG. 6 where the state of the object 110 is represented using lower bits of the pointer to the type information block 120 for an object 110.

[0009] Comparing FIG. 6 and FIG. 7, in either case of operation 1 and operation 2, a code that executes a logical operation “and r12, ˜(2^(n)−1)” is added after “load r12, [r3]” in the first line.

[0010] As mentioned above, in a computer system that implements an object-oriented programming language, how to provide runtime representation of the state of the object has a great effect on the execution efficiency of a processing system. Therefor, it is highly desired to provide runtime representation of the state of the object to be fast and reduce an effect on the execution efficiency of a processing system.

[0011] However, a fast representation method using bits of the object header has not been practical because only a few bits are available.

[0012] A representation method using lower bits of a pointer to point to a type information block has a problem where an access to information in the type information block gets slower on the whole because logical operations are needed to take out a pointer to the type information block.

[0013] Therefor, it is an object of the present invention to provide a representation method for the state of the object that is fast and has an extremely little effect on the execution efficiency of a processing system.

SUMMARY OF THE INVENTION

[0014] Accordingly, the present invention provides a computer system that implements an object-oriented programming language, comprises an object, a type information block, and a class structure as runtime representation for an object in the object-oriented programming language, wherein the object has a header including a pointer to the type information block and data itself, wherein the type information block has a class pointer pointing to the class structure and a virtual method table, wherein a plurality of class pointers are provided depending on the number of states of the object to be represented and individual class pointers are associated with individual states of the object, wherein the pointer included in the header of the object uses lower bits of the pointer to point to the class pointers individually in order to represent the states of the object.

[0015] The class pointers of the type information block are provided in multilevel. According to this configuration, the number of bits of the pointer included in the header of the object required to represent the states of the object is favorably restrained.

[0016] The pointer included in the header of the object uses m middle bits to point to 2^(m) class pointers in order to represent 2^(m) states of the object. According to this configuration, the state of the object can be favorably determined by easy bit test.

[0017] Further, the number of class pointers is 2^(m) and the size of the class pointers is 2^(n) bytes, and further allocating the type information block so that (m+n) lower bits of the pointer included in the header of the object be (2^(m)−1)−(2^(n)−1) when the pointer points to the class pointer at the highest address in the type information block, then allocating 2^(m) class pointers in multilevel toward a lower address from the class pointer pointed by the pointer.

[0018] According to this configuration, this pointer slides the multileveled class pointers in the type information block by changing values of m bits ranging from (m+n)-th bit to (n+1)-th bit of the pointer in the object, thereby enabling efficient representation of the states of the object.

[0019] In another aspect of the invention, a virtual machine that executes a program described in an object-oriented programming language on a computer system, comprises an object, a type information block, and a class structure as runtime representation for an object in the object-oriented programming language, wherein the object has a header including a pointer to the type information block and data itself, wherein the type information block has a class pointer pointing to the class structure and a virtual method table, wherein a plurality of class pointers are provided depending on the number of states of the object to be represented and individual class pointers are associated with individual states of the object, wherein the pointer included in the header of the object uses lower bits of the pointer to point to the class pointers individually in order to represent the states of the object.

[0020] The class pointers of the type information block in the virtual machine are provided in multilevel. According to this configuration, the number of bits of the pointer included in the header of the object required to represent the states of the object is favorably restrained.

[0021] In a further aspect of the invention, a method for runtime representation of an object described in an object-oriented programming language when executing the object on a computer system that implements the object-oriented programming language, comprises an object, a type information block having a plurality of class pointers corresponding to the states of the object, and a class structure pointed by the class pointers; wherein the number of class pointers is 2^(m) and the size of the class pointers is 2^(n) bytes, and further allocating the type information block so that (m+n) lower bits of a pointer included in a header of the object be (2^(m)−1)−(2^(n)−1) when the pointer points to the class pointer at the highest address in the type information block, then allocating 2^(m) class pointers in multilevel toward a lower address from the class pointer pointed by the pointer, thereby a value of the pointer pointing to the type information block is set to a value pointing to the class pointer associated with the current state of the object. Initial values of (m+n) lower bits of the pointer included in the header of the object to point to the type information block are set where high order m digits are 1s and low order digits are 0s, wherein the values of (m+n) lower bits of the pointer are changed depending on the change of state of the object in order to point to the class pointer corresponding to that state.

[0022] According to this configuration, clearing a bit represents the change of state of the object and the state is identified by a simple bit test. A value to be changed to actually specify the state corresponds to high order m digits in lower (m+n) bits of this pointer.

[0023] In a further aspect of the invention, storage media for storing a program that is readable by input means of a computer, comprises a software product implementing a processing system for an object-oriented programming language, wherein an object, a type information block, and a class structure are provided as runtime representation of the object in the object-oriented programming language that is implemented in the computer, wherein the object has a header including a pointer to the type information block and data itself, wherein the type information block has class pointers pointing to the class structure and a virtual method table, wherein the class pointers are provided in multilevel depending on the number of states of the object to be represented and individual class pointers are associated with individual states of the object, wherein the pointer included in the header of the object uses lower bits of the pointer to point to the class pointers individually in order to represent the states of the object.

[0024] According to this configuration, in all computer systems where this software product has been installed, state representation of an object is favorably performed using multileveled class pointers in the type information block.

[0025] In this software product, the pointer included in the header of the object uses m middle bits to point to 2^(m) class pointers in order to represent 2^(m) states of the object. Further, in this software product, the number of class pointers is 2^(m) and the size of the class pointers is 2^(n) bytes, and further allocating the type information block so that (m+n) lower bits of the pointer included in the header of the object be (2^(m)−1)−(2n−1) when the pointer points to the class pointer at the highest address in the type information block, then allocating 2^(m) class pointers in multilevel toward a lower address from the class pointer pointed by the pointer.

[0026] In a further aspect of the invention, a program transmission apparatus, comprising: storage means for storing a software product implementing a processing system for an object-oriented programming language, wherein an object, a type information block, and a class structure are provided as runtime representation of the object in the object-oriented programming language that is implemented in the computer, wherein the object has a header including a pointer to the type information block and data itself, wherein the type information block has class pointers pointing to the class structure and a virtual method table, wherein the class pointers of the type information block are provided in multilevel depending on the number of states of the object to be represented and individual class pointers are associated with individual states of the object, wherein the pointer included in the header of the object uses lower bits of the pointer to point to the class pointers individually in order to represent the states of the object; and transmission means for reading a program from the storage means and transmitting the program.

[0027] According to this configuration, in all computer systems that download and execute this software product, state representation of an object is favorably performed using multileveled class pointers in the type information block.

[0028] In this software product, the pointer included in the header of the object uses m middle bits to point to 2^(m) class pointers in order to represent 2^(m) states of the object.

[0029] Further, in this software product, the number of class pointers is 2^(m) and the size of the class pointers is 2^(n) bytes, and further allocating the type information block so that (m+n) lower bits of the pointer included in the header of the object be (2^(m)−1)−(2^(n)−1) when the pointer points to the class pointer at the highest address in the type information block, then allocating 2^(m) class pointers in multilevel toward a lower address from the class pointer pointed by the pointer.

BRIEF DESCRIPTION OF THE DRAWINGS

[0030]FIG. 1 depicts the arrangement of an object that is used in a computer system that implements an object-oriented programming language in an embodiment of the present invention.

[0031]FIG. 2 is a diagram for explaining the configuration of the type information block in an embodiment of the present invention.

[0032]FIG. 3 shows a modified example of operation codes shown in FIG. 6, where the state of the object is represented using (m+n) lower bits of a pointer to the type information block, according to an embodiment of the invention.

[0033]FIG. 4 shows a contrast between code lines where lopsided branch characteristics are not used and code lines where lopsided branch characteristics are used.

[0034]FIG. 5 depicts the arrangement of an object that is typically used in conventional implementation of an object-oriented programming language.

[0035]FIG. 6 shows an example of operation codes when executing an operation to refer to a member located in offset “o” in the class structure(operation 1) and an operation to call a method that corresponds to an index “i” in the virtual method table (operation 2).

[0036]FIG. 7 shows a modification of operation codes shown in FIG. 6 where the state of the object is represented using lower bits of the pointer to the type information block.

[0037]FIG. 8 depicts a computer system where an object-oriented programming language is implemented by mounting a virtual machine.

DESCRIPTION OF THE SYMBOLS

[0038]10: Object

[0039]11: Header

[0040]12: Body

[0041]20: Type information block

[0042]21: Class pointer section

[0043]21 a, 21 b, 21 c, 21 d: Class pointer

[0044]22: Virtual method table

[0045]30: Class structure

DETAILED DESCRIPTION

[0046] Hereinafter, the present invention will be described in detail referring to the accompanying drawings. FIG. 1 depicts the arrangement of an object that is used in a computer system that implements an object-oriented programming language in an embodiment of the present invention. As is shown in FIG. 8, the implementation of an object-oriented programming language is achieved by mounting a virtual machine or a processing system of the programming language that is provided by a compiler, etc. (in the shown drawing, virtual machines of Java and Smalltalk) on a computer system.

[0047] In FIG. 1, a symbol 10 indicates an object, a symbol 20 indicates a type information block, and a symbol 30 indicates a class structure.

[0048] The object 10 is composed of a header 11 and a body of program modules 12, and the header 11 stores a pointer(that is called “T pointer” hereinafter) to the type information block 20.

[0049] The type information block 20 is composed of a class pointer section 21 and a virtual method table 22. FIG. 2 is a diagram for explaining the configuration of the type information.

[0050] Referring to FIG. 2, the class pointer section 21 is what a class pointer 121 in the conventional type information block 120 shown in FIG. 5 is extended in multilevel toward a lower address. Thereby a plurality of class pointers is established in the class pointer section 21. These class pointers are associated with the states of the object to be represented, i.e. when representing 2^(m) states of the object, 2^(m) class pointers are correspondingly established in the class pointer section 21. In the example shown in FIG. 2, four(m=2) class pointers 21 a-21 d are established. In the embodiment of the present invention, states of the object are represented by utilizing the configuration of the above type information block 20 and further using predetermined bits of the header 11 of the object 10. 2^(m) states of the object are represented by using m bits. Assuming that the size of each class pointer 21 a-21 d in the class pointer section 21 of the type information block 20 is 2^(n) bytes, m lower bits(ranging from (m+n)-th bit to (n+1)-th bit) of T pointer are used.

[0051] Values of these bits are initially set to “1”, then a transition of the state is represented by clearing a bit, i.e. setting to “0”, while the state is determined by bit test. This determination of state is extremely simple as well as the above-mentioned prior art where the states of the object 110 are represented by only using the bits of the header 111 of the object 110.

[0052] Next, how to configure the type information block 20 will be described. As described above, the class pointer section 21 is formed by extending the class pointers 21 a-21 d in multilevel toward a lower address from class pointer 21 a. Now, among T pointers in the header 11 of the object 10 that point to the type information block 20, we call T pointer that points to the class pointer 21 a at the highest address as “base T pointer”.

[0053] Then we allocate the type information block 20 so that (m+n) lower bits of the base T pointer defined in this manner should be (2^(m)−1)−(2^(n)−1).

[0054] Next, allocating 2^(m) class pointers in multilevel toward a lower address from the address pointed by this base T pointer.

[0055]FIG. 1 and FIG. 2 show an example when m=2, n=2, where it is seen that lower bits(2+2 bits) of the base T pointer are 1100, and 4(=2²) class pointers 21 a-21 d are allocated.

[0056] With the scheme for configuring the type information block 20 in this manner, base T pointer will be stored in the header 11 when the header 11 of the object 10 is initialized.

[0057] Thereafter, the value of the T pointer to the type information block 20 changes depending on the change of state of the object 10, however, it will slide to any one of multileveled class pointers 21 a-21 d.

[0058] As described above, when accessing the class pointers 21 a-21 d, values of these class pointers are immediately acquired from T pointer according to the multilevel structure. Therefor, an overhead is zero.

[0059] On the other hand, when accessing the virtual method table 22, T pointer needs to be transformed to base T pointer prior to the access. More specifically, logical OR operation, where the value of T pointer at that time is ORed with the value of (m+n) lower bits of base T pointer, i.e. (2^(m)−1)−(2^(n)−1), is performed. Therefor, an overhead occurs in similar manner to the prior art shown in FIG. 5 where the states of the object 110 are represented using lower bits of the pointer to the type information block 120.

[0060]FIG. 3 shows a modified example of operation codes shown in FIG. 6, where the state of the object 10 is represented using (m+n) lower bits of T pointer in the header 11 of object 10, according to an embodiment of the invention.

[0061] Comparing FIG. 3 and FIG. 6, in operation 1 where referring to a member in the class structure 30 at offset “o”, both codes are the same, however, in operation 2 where calling a method at index “i” in the virtual method table 22, a logical operation code

or r12, (2^(m)−1)−(2^(n)−1)

[0062] is added after the first line, i.e. load r12, [r3].

[0063] In this manner, access performance to the class structure where a lot of important data are included does not degrade. Therefor, in a language or a processing system such as Java where an access to class pointers 21 a-21 d mainly occurs and the virtual method table 22 is infrequently accessed, execution efficiency does not significantly degrade. However, it can not be denied that execution efficiency might be significantly influenced depending on a language or a processing system.

[0064] But if T pointer in the header 11 of the object 10 hardly changes from base T pointer, i.e. the state of the object 10 hardly changes and point of T pointer hardly changes from class pointer 21 a, a processor that has the parallel execution capability on instruction level and a hardware for branch prediction, an influence on execution performance can be reduced by using lopsided branch characteristics.

[0065]FIG. 4 shows a contrast between code lines where lopsided branch characteristics are not used(code lines 1 hereinafter) and code lines where lopsided branch characteristics are used(code lines 2 hereinafter). In each code shown in FIG. 4, “lwz” corresponds to “load” in FIG. 3, “ori” corresponds to “or” in FIG. 3, and “mtctr” corresponds to “call” in FIG. 3. “cmp” compares the values of registers, “be+” branches based on the comparison result of “cmp”, and “mr” moves a register value.

[0066] Referring to FIG. 4, in the code lines 2, the third line and forth line, i.e.

[0067] retry:

[0068] cmp cr0, r12 r0

[0069] and the sixth line to ninth line, i.e.

[0070] be+docall

[0071] mr r0, r12

[0072] b retry

[0073] docall:

[0074] are added to the code lines 1.

[0075] In code lines 1, total five cycles are required to reach “mtctr”, including 2 cycles in “lwz”, 1 cycle in “ori”, and 2 cycles in “lwz”. Since these three instructions have data dependency, they can not be executed in parallel so that five cycles are necessarily needed to execute them.

[0076] In contrast, code lines 2 are executed in the following order, i.e. lwz(2 cycles), ori(1 cycle), cmp(1 cycle), lwz(2 cycles), be+(1 cycle) and mtctr. Here ori(1 cycle), cmp(1 cycle) are executed in parallel with the second “lwz”. Further “be” is considered to consume near 0 cycle since prediction with the branch prediction hardware almost hits. Therefor these instructions are executed in four cycles after all.

[0077] Executing the parallel processing using the lopsided branch characteristics in this manner, it becomes possible to reduce the degradation of execution performance.

[0078] As mentioned above, according to the present invention, in order to represent the state of the object, a representation method to be fast and have an extremely little effect on the execution efficiency of a processing system can be implemented. 

1. A computer system that implements an object-oriented programming language, comprising: an object, a type information block, and a class structure as runtime representation for an object in the object-oriented programming language; the object having a header including a pointer to the type information block and data itself, the type information block having a class pointer pointing to the class structure and a virtual method table, a plurality of class pointers are provided depending on the number of states of the object to be represented and individual class pointers are associated with individual states of the object, wherein the pointer included in the header of the object uses lower bits of the pointer to point to the class pointers individually in order to represent the states of the object sad computer system changing a value of said pointer so that an efficient runtime representation of an object's state using one of said plurality of class pointers in said type information block is available when executing in said computer system.
 2. The computer system according to claim 1, wherein the class pointers of the type information block are provided in multilevel.
 3. The computer system according to claim 1, wherein the pointer included in the header of the object uses m middle bits to point to 2^(m) class pointers in order to represent 2^(m) states of the object.
 4. The computer system according to claim 1, wherein the number of class pointers is 2^(m) and the size of the class pointers is 2^(n) bytes, and further allocating the type information block so that (m+n) lower bits of the pointer included in the header of the object be (2^((m+n))−1)−(2^(n)−1) when the pointer points to the class pointer at the highest address in the type information block, then allocating 2^(m) class pointers in multilevel toward a lower address from the class pointer pointed by said pointer.
 5. A virtual machine that executes a program described in an object-oriented programming language on a computer system, comprising: an object, a type information block, and a class structure as runtime representation for an object in the object-oriented programming language, the object having a header including a pointer to the type information block and data itself, the type information block having a class pointer pointing to the class structure and a virtual method table, a plurality of class pointers are provided depending on the number of states of the object to be represented and individual class pointers are associated with individual states of the object, wherein the pointer included in the header of the object uses lower bits of the pointer to point to the class pointers individually in order to represent the states of the object, said virtual machine changing a value of said pointer so that an efficient runtime representation of an object's state using one of said plurality of class pointers in said type information block is available when executing in said virtual machine.
 6. The virtual machine according to claim 5, wherein the class pointers of the type information block are provided in multilevel.
 7. A method for runtime representation of an object described in an object-oriented programming language when executing the object on a computer system that implements the object-oriented programming language, comprises an object, a type information block having a plurality of class pointers corresponding to the states of the object, and a class structure pointed by the class pointers; wherein the number of class pointers is 2^(m) and the size of the class pointers is 2^(n) bytes, and allocating the type information block so that (m+n) lower bits of a pointer included in a header of the object be (2^((m+n))−1)−(2^(n)−1) when the pointer points to the class pointer at the highest address in the type information block, then allocating 2^(m) class pointers in multilevel toward a lower address from the class pointer pointed by said pointer, and, setting a value of said pointer so that an efficient runtime representation of an object's state using one of said 2^(m) class pointers in said the information block is available when executing in said computer system.
 8. The method according to claim 7, wherein initial values of (m+n) lower bits of the pointer included in the header of the object to point to the type information block are set where high order m digits are 1s and low order digits are 0s, wherein the values of (m+n) lower bits of the pointer are changed depending on the change of state of the object in order to point to the class pointer corresponding to that state.
 9. A storage media for storing a program that is readable by input means of a computer, comprising a software product implementing a processing system for an object-oriented programming language, wherein an object, a type information block, and a class structure are provided as runtime representation of the object in the object-oriented programming language that is implemented in the computer, the object having a header including a pointer to the type information block and data itself, the type information block having class pointers pointing to the class structure and a virtual method table, the class pointers are provided in multilevel depending on the number of states of the object to be represented and individual class pointers are associated with individual states of the object, wherein the pointer included in the header of the object uses lower bits of the pointer to point to the class pointers individually in order to represent the states of the object, said computer changing a value of said pointer so that an efficient runtime representation of an object's state using one of said class pointers in said type information block is available when executing in said virtual machine.
 10. The storage media according to claim 9, wherein the pointer included in the header of the object uses m middle bits to point to 2^(m) class pointers in order to represent 2^(m) states of the object.
 11. The storage media according to claim 9, wherein the number of class pointers is 2^(m) and the size of the class pointers is 2^(n) bytes, and further allocating the type information block so that (m+n) lower bits of the pointer included in the header of the object be (2^((m+n))−1)−(2^(n)−1) when the pointer points to the class pointer at the highest address in the type information block, then allocating 2^(m) class pointers in multilevel toward a lower address from the class pointer pointed by said pointer.
 12. A program transmission apparatus, comprising: a storage means for storing a software product implementing a processing system for an object-oriented programming language, wherein an object, a type information block, and a class structure are provided as runtime representation of the object in the object-oriented programming language that is implemented in the computer, the object having a header including a pointer to the type information block and data itself, the type information block having class pointers pointing to the class structure and a virtual method table, the class pointers of the type information block are provided in multilevel depending on the number of states of the object to be represented and individual class pointers are associated with individual states of the object, wherein the pointer included in the header of the object uses lower bits of the pointer to point to the class pointers individually in order to represent the states of the object; and a transmission means for reading a program from the storage means and transmitting the program.
 13. The program transmission apparatus according to claim 12, wherein the pointer included in the header of the object uses m middle bits to point to 2^(m) class pointers in order to represent 2^(m) states of the object.
 14. The program transmission apparatus according to claim 12, wherein the number of class pointers is 2^(m) and the size of the class pointers is 2^(n) bytes, and further allocating the type information block so that (m+n) lower bits of the pointer included in the header of the object be (2^((m+n))−1)−(2^(n)−1) when the pointer points to the class pointer at the highest address in the type information block, then allocating 2^(m) class pointers in multilevel toward a lower address from the class pointer pointed by said pointer. 